Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> Python

Python

  1. Python में String से Characters की List कैसे Remove करें?

    String से Multiple Characters Remove करना String Class में replace Method होता है जिसका उपयोग String में Substrings Replace करने के लिए किया जा सकता है। हम इस Method का उपयोग उन Characters को Empty String से Replace करने के लिए कर सकते हैं जिन्हें हम Remove करना चाहते हैं। Single Character Remove

  2. पायथन CSV स्ट्रिंग को सरणी में कैसे बदलें

    सबसे आसान तरीका है str.split मेथड का उपयोग करके हर , की घटना पर विभाजित करना और हर स्ट्रिंग को strip मेथड से मैप करके किसी भी अग्रणी/अनुगामी व्हाइटस्पेस को हटाना। उदाहरण के लिए, >>> s = 1, John Doe, Boston, USA >>> print(map(str.strip, s.split(,))) [1, John Doe, Boston, USA] यदि आप

  3. Python में String में Substring की nth Occurrence कैसे Find करें?

    Substring की nth Occurrence Find करना आप Substring पर Max n+1 Splits के साथ Split करके String में Substring की nth Occurrence Find कर सकते हैं। यदि Resulting List का Size n+1 से Greater है, तो इसका मतलब है कि Substring n से अधिक बार Occur होती है। इसका Index Simple Formula से पाया जा सकता है: Origi

  4. क्या हम Python Strings पर Math Operations कर सकते हैं?

    Strings पर Mathematical Expressions Evaluate करना आप Mathematical Expressions को Strings में Evaluate करने के लिए eval Function का उपयोग कर सकते हैं। उदाहरण उदाहरण के लिए, यदि आपके पास Content (4*5) + 21 वाला String है, तो आप इसे Eval कर सकते हैं और Result प्राप्त कर सकते हैं। >>> s = (4*

  5. Python में %r के बजाय %s कब उपयोग करें?

    %s vs %r: String Formatting में Difference %s Specifier Object को str() का उपयोग करके Convert करता है, और %r इसे repr() का उपयोग करके Convert करता है। कुछ Objects जैसे Integers के लिए, वे Same Result देते हैं, लेकिन repr() इसमें Special है कि (उन Types के लिए जहां यह संभव है) यह Conventionally ऐसा

  6. Python में '+' Operator के बिना String Concatenation कैसे करें?

    + Operator के बिना String Concatenation आप String Class से str.join(list_of_strings) का उपयोग कर सकते हैं। जिस String पर आप इसे Call करते हैं, उसका उपयोग आपके द्वारा Argument के रूप में Provide की गई Strings की List को Join करने के लिए किया जाता है। उदाहरण >>> .join([Hello, World]) Hello

  7. Python में कैसे बताएं कि String खुद को Repeat करती है?

    String Periodicity Check करना हम Check करना चाहते हैं कि हमारे पास जो String है वह इस String के Substring की Repetitions से Composed है या नहीं। इसे Check करने के लिए हम Check कर सकते हैं कि String का कोई Rotation 2 Strings के Combination में Exist करता है या नहीं। ऐसा इसलिए क्योंकि एक String Perio

  8. Python का उपयोग करके String को JSON में Convert कैसे करें?

    JSON String को Dictionary में Convert करना JSON String को Dictionary में Convert करने के लिए json.loads() का उपयोग करें। यह Method Valid JSON String Accept करता है और Dictionary Return करता है जिसमें आप सभी Elements Access कर सकते हैं। उदाहरण >>> import json >>> s = {success: tru

  9. Python में String के End से Substring कैसे Remove करें?

    String के End से Substring Remove करना यदि आप String के End से Substring Remove करना चाहते हैं, तो पहले Check करें कि String उस Substring से End होती है या नहीं। यदि करती है, तो String को Slice करके केवल बिना Substring वाला Part रखें। उदाहरण: Custom Function def rchop(string, ending): if strin

  10. Multi-line String को Multiple Lines में कैसे Split करें?

    Multi-line String Split करना हम String Class में splitlines() Method का उपयोग करके इसे Achieve कर सकते हैं। उदाहरण >>> some multi line string.splitlines() [some, multi line, string] हम split() Method में Delimiter \n Specify करके भी कर सकते हैं: >>> some multi line string.split(

  11. Python में Semicolon-separated String को Dictionary में Split कैसे करें?

    Semicolon-separated String को Dictionary में Convert करना यदि आपके पास इस तरह के Strings हैं: Name1=Value1;Name2=Value2;Name3=Value3 और आप इसे Dictionary में Convert करना चाहते हैं, तो यह काफी आसान है। आप बस ; पर Split कर सकते हैं और फिर = पर Split करके इसे Dict Constructor में Pass कर सकते हैं।

  12. Python Dictionary को String में Serialize कैसे करें और Vice Versa?

    Dictionary Serialization: JSON Python Dictionary का String में Best Representation JSON है। आप Dictionary को String में Convert करने के लिए json.dumps(dict) का उपयोग कर सकते हैं। और String से Dictionary वापस पाने के लिए json.loads(string) का उपयोग कर सकते हैं। उदाहरण >>> import json >&

  13. Python में String को Words की List में कैसे Convert करें?

    String को Words की List में Convert करना String को Words की List में Convert करने के लिए, आपको बस इसे Whitespace पर Split करना होगा। String Class से split() का उपयोग कर सकते हैं। इस Method का Default Delimiter Whitespace होता है, यानी जब String पर Call किया जाता है, तो यह उस String को Whitespace Ch

  14. Python में String को Capitalize कैसे करें?

    String Capitalize करना तरीका 1: capitalize() Method (First Word Only) यदि आप केवल String के First Word के First Letter को Capitalize करना चाहते हैं, तो String Class के capitalize Method का उपयोग करें। >>> s = my name >>> s.capitalize() My name तरीका 2: Manual Slicing >>>

  15. Python में String और Byte String में क्या Difference है?

    String vs Byte String एक String Characters का Sequence होता है; ये एक Abstract Concept हैं और इन्हें Directly Disk पर Store नहीं किया जा सकता। एक Byte String Bytes का Sequence होती है - ऐसी चीजें जो Disk पर Store की जा सकती हैं। इनके बीच Mapping को Encoding कहते हैं - इनमें से काफी सारे हैं (और अनं

  16. Python में String के Letters को Alphabetically Sort कैसे करें?

    String के Letters को Alphabetically Sort करना String के Letters को Alphabetically Sort करने के लिए, आपको sorted Function का उपयोग करना होगा जो Letters की Sorted List Return करता है जिसे आप फिर Join करके String प्राप्त कर सकते हैं। Basic Example: >>> s = helloworld >>> .join(sorte

  17. Python 3 में Dictionary का उपयोग करके String Format कैसे करें?

    Dictionary के साथ String Formatting आप Strings को Interpolate करने के लिए Dictionaries का उपयोग कर सकते हैं। इनका एक Syntax होता है जिसमें आपको % और Conversion Character के बीच Parentheses में Key Provide करना होता है। उदाहरण उदाहरण के लिए, यदि आपके पास Key cost में Float Stored है और आप इसे $xxxx

  18. Python में String को निश्चित Length तक Repeat करने का Efficient तरीका?

    String को Specific Length तक Repeat करना यदि आप String को n Characters तक Repeat करना चाहते हैं, तो आप पहले Whole String को n/len(s) Times Repeat कर सकते हैं और अंत में n%len(s) Characters Add कर सकते हैं। उदाहरण 1: Manual Calculation def repeat_n(string, n): l = len(string) full_rep = n /

  19. Python में सबसे Efficient String Concatenation Method कौन सा है?

    String Concatenation के Efficient Methods String Variable में String Append करने का Best तरीका + या += का उपयोग करना है। ऐसा इसलिए क्योंकि यह Readable और Fast है। वे उतने ही Fast हैं। इसके अलावा, यदि आप 2 Strings के साथ काम कर रहे हैं, तो append() का भी उपयोग किया जा सकता है। यदि आप Strings की Li

  20. Python String की Max Length क्या है?

    Python String की Maximum Length 64-bit Python Installation और 64 GB Memory के साथ, लगभग 63 GB की Python 2 String काफी Feasible होनी चाहिए। यदि आप अपनी Memory को इससे कहीं अधिक Upgrade कर सकते हैं, तो आपकी Maximum Feasible Strings आनुपातिक रूप से Longer होनी चाहिए। लेकिन यह Runtimes पर Hit के साथ आ

Total 9001 -कंप्यूटर  FirstPage PreviousPage NextPage LastPage CurrentPage:14/451  20-कंप्यूटर/Page Goto:1 8 9 10 11 12 13 14 15 16 17 18 19 20