सभी tools
निःशुल्क

एक खोजने योग्य, प्रिंट करने योग्य Python 3 संदर्भ — सिंटैक्स, डेटा संरचनाएँ, कॉम्प्रिहेंशन, फंक्शन, क्लास, फाइलें और स्टैंडर्ड लाइब्रेरी। मुफ्त।

वेरिएबल और टाइप

10
x = 1
वेरिएबल असाइन करें (गतिशील रूप से टाइप)
x: int = 1
वैकल्पिक टाइप एनोटेशन
a, b = 1, 2
एकाधिक असाइनमेंट
type(x)
मान का टाइप प्राप्त करें
int('42')
string को integer में बदलें
str(42)
मान को string में बदलें
isinstance(x, int)
टाइप जाँच
None
null/अनुपस्थिति मान
x = y = 0
चेन किया गया असाइनमेंट
PI: Final = 3.14
Constant संकेत (typing.Final)

Strings

11
f'Hello {name}'
f-string इंटरपोलेशन
len(s)
String लंबाई
s.upper()
upper case में बदलें
s.strip()
आसपास का whitespace हटाएँ
s.split(',')
list में विभाजित करें
','.join(items)
विभाजक के साथ list जोड़ें
s.replace('a', 'b')
substrings बदलें
'a' in s
सदस्यता परीक्षण
s[1:4]
वर्ण 1 से 3 स्लाइस करें
s[::-1]
string उलटें
s.startswith('a')
prefix जाँचें

Lists और tuples

10
a = [1, 2, 3]
list बनाएँ
a.append(4)
अंत में आइटम जोड़ें
a.insert(0, x)
किसी index पर डालें
a.pop()
अंतिम आइटम हटाएँ और लौटाएँ
a[1:3]
उप-सूची स्लाइस करें
sorted(a, reverse=True)
क्रमबद्ध प्रति लौटाएँ
a.sort(key=len)
key के अनुसार जगह पर sort करें
len(a)
आइटमों की संख्या
t = (1, 2)
Immutable tuple
first, *rest = a
star के साथ unpack करें

Dicts और sets

10
d = {'k': 'v'}
dictionary बनाएँ
d['k']
key द्वारा मान एक्सेस करें
d.get('k', default)
fallback के साथ प्राप्त करें
d.keys() / d.values()
keys या values देखें
d.items()
key/value जोड़ों पर इटरेट करें
{**a, **b}
dictionaries मर्ज करें
a | b
Dict/set union operator
del d['k']
key हटाएँ
s = {1, 2, 3}
set बनाएँ (अद्वितीय मान)
set(a) & set(b)
Set प्रतिच्छेदन

Comprehensions

8
[x * 2 for x in a]
List comprehension
[x for x in a if x > 0]
फ़िल्टर की गई comprehension
{x: x**2 for x in a}
Dict comprehension
{x for x in a}
Set comprehension
(x for x in a)
Generator एक्सप्रेशन (lazy)
[y for row in m for y in row]
नेस्टेड loops के साथ flatten करें
[a if c else b for x in items]
comprehension में सशर्त मान
sum(x for x in a)
generator को एकत्रित करें

Control flow

9
if x > 0:\n ...
सशर्त (indentation मायने रखता है)
elif / else:
अतिरिक्त शाखाएँ
a if cond else b
Ternary एक्सप्रेशन
for x in range(10):
range पर loop करें
for i, x in enumerate(a):
index के साथ loop करें
for a, b in zip(x, y):
दो iterables को एक साथ loop करें
while cond:
जब तक true है loop करें
break / continue
इटरेशन से बाहर निकलें या छोड़ें
match x:\n case 1: ...
Structural pattern matching (3.10+)

फंक्शन

8
def f(a, b=1): return a + b
डिफ़ॉल्ट argument वाला function
def f(*args, **kwargs):
Variadic positional + keyword args
f(name='Sam')
keyword argument के साथ कॉल करें
lambda x: x + 1
अनाम inline function
def f(a: int) -> int:
params और return के लिए टाइप hints
@decorator
decorator के साथ function लपेटें
yield value
generator से मान उत्पन्न करें
global x / nonlocal x
बाहरी-स्कोप वेरिएबल को फिर से bind करें

Classes

9
class A(Base):
इनहेरिटेंस वाली class
def __init__(self, x):
Constructor / initializer
self.x = x
Instance attribute
def __str__(self):
String प्रतिनिधित्व
@property
गणना की गई read-only attribute
@staticmethod / @classmethod
Static और class methods
super().__init__()
parent initializer को कॉल करें
@dataclass
init/repr/eq स्वतः उत्पन्न करें
isinstance(obj, A)
instance टाइप जाँचें

फ़ाइलें, errors और modules

9
with open('f.txt') as fh:
फ़ाइल खोलें (स्वतः बंद)
fh.read() / fh.readlines()
फ़ाइल सामग्री पढ़ें
open('f.txt', 'w').write(s)
फ़ाइल में लिखें
try:\n ...\nexcept ValueError as e:
विशिष्ट exception पकड़ें
raise ValueError('bad')
exception raise करें
finally:
हमेशा-चलने वाला cleanup ब्लॉक
import os
module इम्पोर्ट करें
from math import sqrt
विशिष्ट नाम इम्पोर्ट करें
import numpy as np
alias के साथ इम्पोर्ट करें

कोई प्रविष्टि “:q” से मेल नहीं खाती।


इसे साझा करें
मदद चाहिए?
इस टूल में कोई समस्या मिली? हमारी टीम को बताएं।
समस्या की रिपोर्ट करें

इस मुफ़्त टूल को अपनी वेबसाइट पर जोड़ें — नीचे दिया गया कोड कॉपी और पेस्ट करें।