🌟ساخت کامل ایستگاه هواشناسی توسط رزبری پای با امکان ترسیم گراف عملکرد
http://www.trainelectronics.com/RaspberryPi/WX_Station/index.htm
@raspberry_python
http://www.trainelectronics.com/RaspberryPi/WX_Station/index.htm
@raspberry_python
#آموزش 1 📚
جهت #unzip کردن فایل های #zip در پایتون از دستور زیر استفاده می شود.
file_unzip = 'filename.zip'
unzip = zipfile.ZipFile(file_unzip, 'r')
unzip.extractall()
unzip.close()
@raspberry_python
جهت #unzip کردن فایل های #zip در پایتون از دستور زیر استفاده می شود.
file_unzip = 'filename.zip'
unzip = zipfile.ZipFile(file_unzip, 'r')
unzip.extractall()
unzip.close()
@raspberry_python
#آموزش 2 📚
برای خواندن فایل در پایتون به صورت خط به خط از دستور زیر استفاده می شود.
with open('myfile.txt', 'r') as fp:
for line in fp:
print(line)
@raspberry_python
برای خواندن فایل در پایتون به صورت خط به خط از دستور زیر استفاده می شود.
with open('myfile.txt', 'r') as fp:
for line in fp:
print(line)
@raspberry_python
#آموزش 3 📚
#Itertools
ماژول itertools در پایتون :
این ماژول تمام ترکیبات ممکن k تایی در یک لیست را نشان می دهد.
در مثال زیر k=2 می باشد.
import itertools
a = [1,2,3,4,5]
b = list(itertools.combinations(a, 2))
print(b)
Output:
[(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 5)]
اگر k=3 باشد داریم :
import itertools
a = [1,2,3,4,5]
b = list(itertools.combinations(a, 3))
print(b)
Output:
[(1, 2, 3), (1, 2, 4), (1, 2, 5), (1, 3, 4),
(1, 3, 5), (1, 4, 5), (2, 3, 4), (2, 3, 5),
(2, 4, 5), (3, 4, 5)]
@raspberry_python
#Itertools
ماژول itertools در پایتون :
این ماژول تمام ترکیبات ممکن k تایی در یک لیست را نشان می دهد.
در مثال زیر k=2 می باشد.
import itertools
a = [1,2,3,4,5]
b = list(itertools.combinations(a, 2))
print(b)
Output:
[(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 5)]
اگر k=3 باشد داریم :
import itertools
a = [1,2,3,4,5]
b = list(itertools.combinations(a, 3))
print(b)
Output:
[(1, 2, 3), (1, 2, 4), (1, 2, 5), (1, 3, 4),
(1, 3, 5), (1, 4, 5), (2, 3, 4), (2, 3, 5),
(2, 4, 5), (3, 4, 5)]
@raspberry_python
#آموزش 4 📚
تبدیل #لیست به #دیکشنری در پایتون
l = ['alpha', 'beta', 'gamma', 'delta']
a = dict(zip(range(len(l)), l))
print(a)
output:
{0: 'alpha', 1: 'beta', 2: 'gamma', 3: 'delta'}
@raspberry_python
تبدیل #لیست به #دیکشنری در پایتون
l = ['alpha', 'beta', 'gamma', 'delta']
a = dict(zip(range(len(l)), l))
print(a)
output:
{0: 'alpha', 1: 'beta', 2: 'gamma', 3: 'delta'}
@raspberry_python
#آموزش 5
#function
🔴 توصیف توابع ،بسیار کاربردی🔴
📌int(x [,base])
Converts x to an integer. base specifies the base if x is a string.
〰〰〰〰〰〰〰〰〰〰〰〰
📌long(x [,base] )
Converts x to a long integer. base specifies the base if x is a string.
〰〰〰〰〰〰〰〰〰〰〰〰
📌float(x)
Converts x to a floating-point number.
〰〰〰〰〰〰〰〰〰〰〰
📌complex(real [,imag])
Creates a complex number.
〰〰〰〰〰〰〰〰〰〰〰〰
📌str(x)
Converts object x to a string representation.
〰〰〰〰〰〰〰〰〰〰〰〰
📌🌟repr(x)
Converts object x to an expression string.
〰〰〰〰〰〰〰〰〰〰〰
📌eval(str)
Evaluates a string and returns an object.
〰〰〰〰〰〰〰〰〰〰〰〰
📌tuple(s)
Converts s to a tuple.
〰〰〰〰〰〰〰〰〰〰〰〰〰
📌list(s)
Converts s to a list.
〰〰〰〰〰〰〰〰〰〰〰〰〰
📌set(s)
Converts s to a set.
〰〰〰〰〰〰〰〰〰〰〰〰〰
📌dict(d)
Creates a dictionary. d must be a sequence of (key,value) tuples.
〰〰〰〰〰〰〰〰〰〰〰〰〰
📌frozenset(s)
Converts s to a frozen set.
〰〰〰〰〰〰〰〰〰〰〰〰〰
📌chr(x)
Converts an integer to a character.
〰〰〰〰〰〰〰〰〰〰〰〰
📌unichr(x)
Converts an integer to a Unicode character.
〰〰〰〰〰〰〰〰〰〰〰〰
📌ord(x)
Converts a single character to its integer value.
〰〰〰〰〰〰〰〰〰〰〰〰〰
📌hex(x)
Converts an integer to a hexadecimal string.
〰〰〰〰〰〰〰〰〰〰〰
📌oct(x)
Converts an integer to an octal string.
@raspberry_python
#function
🔴 توصیف توابع ،بسیار کاربردی🔴
📌int(x [,base])
Converts x to an integer. base specifies the base if x is a string.
〰〰〰〰〰〰〰〰〰〰〰〰
📌long(x [,base] )
Converts x to a long integer. base specifies the base if x is a string.
〰〰〰〰〰〰〰〰〰〰〰〰
📌float(x)
Converts x to a floating-point number.
〰〰〰〰〰〰〰〰〰〰〰
📌complex(real [,imag])
Creates a complex number.
〰〰〰〰〰〰〰〰〰〰〰〰
📌str(x)
Converts object x to a string representation.
〰〰〰〰〰〰〰〰〰〰〰〰
📌🌟repr(x)
Converts object x to an expression string.
〰〰〰〰〰〰〰〰〰〰〰
📌eval(str)
Evaluates a string and returns an object.
〰〰〰〰〰〰〰〰〰〰〰〰
📌tuple(s)
Converts s to a tuple.
〰〰〰〰〰〰〰〰〰〰〰〰〰
📌list(s)
Converts s to a list.
〰〰〰〰〰〰〰〰〰〰〰〰〰
📌set(s)
Converts s to a set.
〰〰〰〰〰〰〰〰〰〰〰〰〰
📌dict(d)
Creates a dictionary. d must be a sequence of (key,value) tuples.
〰〰〰〰〰〰〰〰〰〰〰〰〰
📌frozenset(s)
Converts s to a frozen set.
〰〰〰〰〰〰〰〰〰〰〰〰〰
📌chr(x)
Converts an integer to a character.
〰〰〰〰〰〰〰〰〰〰〰〰
📌unichr(x)
Converts an integer to a Unicode character.
〰〰〰〰〰〰〰〰〰〰〰〰
📌ord(x)
Converts a single character to its integer value.
〰〰〰〰〰〰〰〰〰〰〰〰〰
📌hex(x)
Converts an integer to a hexadecimal string.
〰〰〰〰〰〰〰〰〰〰〰
📌oct(x)
Converts an integer to an octal string.
@raspberry_python
from gpiozero import LED, Button
from signal import pause
led=LED(17)
button=Button(2)
button.when_pressed = led.on button.when_released = led.off
while True:
button.wait_for_press()
@raspberry_python
from signal import pause
led=LED(17)
button=Button(2)
button.when_pressed = led.on button.when_released = led.off
while True:
button.wait_for_press()
@raspberry_python
from gpiozero import LED, Button
from time import sleep
led=LED(17)
button=Button(2)
while True:
button.wait_for_press()
led.toggle()
@raspberry_python
from time import sleep
led=LED(17)
button=Button(2)
while True:
button.wait_for_press()
led.toggle()
@raspberry_python
اتصال رزبری پای به اینترنت با ماژول sim800 و sim900 👇
http://www.rhydolabz.com/wiki/?p=16325
@raspberry_python
http://www.rhydolabz.com/wiki/?p=16325
@raspberry_python
HTTP GET SOCKET.py
1.3 KB
اسکریپت پایتون جهت برقراری ارتباط سوکت با ماژول سیم کام و رزبری پای
نویسنده اسکریپت : مهندس مزدارانی
@raspberryproject
@raspberry_python
نویسنده اسکریپت : مهندس مزدارانی
@raspberryproject
@raspberry_python
Build a Compact 4 Node Raspberry Pi Cluster
http://makezine.com/projects/build-a-compact-4-node-raspberry-pi-cluster/
@raspberry_python
http://makezine.com/projects/build-a-compact-4-node-raspberry-pi-cluster/
@raspberry_python
#آموزش 8
#pyserial
🔴 ارتباطات سریال در پایتون🔴
برای دریافت یک لیست از درگاه های سریال از دستور زیر در cli استفاده می شود.
python -m serial.tools.list_ports
🌟 دستورات ارتباط سریال در پایتون🌟
import serial
تابع Serial دو پارامتر میگیرد :
۱_ دستگاه سریال
۲_ بادریت که معمولا 9600 می باشد.
ser = serial.Serial('/dev/ttyUSB0', 9600)
برای خواندن تک بایت از دستگاه سریال:
data = ser.read()
برای خواندن تعدادی بایت از دستگاه سریال :
data = ser.read(size=5)
برای خواندن یک خط از دستگاه سریال :
data = ser.readline()
برای خواندن داده ها از دستگاه سریال هنگامی که چیزی روی آن نوشته شده است :
در پایتون 2.7
data = ser.read(ser.inWaiting())
در پایتون 3
ser.read(ser.inWaiting)
@raspberry_python
#pyserial
🔴 ارتباطات سریال در پایتون🔴
برای دریافت یک لیست از درگاه های سریال از دستور زیر در cli استفاده می شود.
python -m serial.tools.list_ports
🌟 دستورات ارتباط سریال در پایتون🌟
import serial
تابع Serial دو پارامتر میگیرد :
۱_ دستگاه سریال
۲_ بادریت که معمولا 9600 می باشد.
ser = serial.Serial('/dev/ttyUSB0', 9600)
برای خواندن تک بایت از دستگاه سریال:
data = ser.read()
برای خواندن تعدادی بایت از دستگاه سریال :
data = ser.read(size=5)
برای خواندن یک خط از دستگاه سریال :
data = ser.readline()
برای خواندن داده ها از دستگاه سریال هنگامی که چیزی روی آن نوشته شده است :
در پایتون 2.7
data = ser.read(ser.inWaiting())
در پایتون 3
ser.read(ser.inWaiting)
@raspberry_python