python-2.x
Regex match for a non-english language in Python
I\'m trying to capture and match russian language chara开发者_Python百科cters in a python script. Since russian characters don\'t fall in [a-Z] type, what regex should I should to match them. I can\'t[详细]
2023-02-06 10:18 分类:问答Python encoding conversion
I wrote a Python script that processes CSV files with non-ascii characters, encoded in UTF-8. However the encoding of the output is broken. So, from this in the input:[详细]
2023-02-06 10:04 分类:问答How to pick just one item from a generator?
I have a generator function like the following: def myfunct(): ... yield result The usual way to call this function would be:[详细]
2023-02-05 08:56 分类:问答How to accomplish relative import in python
stuff/ __init__.py mylib.py Foo/ __init__.py main.py foo/ __init__.py script.py script.py wants to import mylib.py[详细]
2023-02-04 02:00 分类:问答Embed variable using sys.stdout.write in Python
I can embed variables using the print statement in python in this way i=10 print \"Value is %s\" % (i) Output[详细]
2023-02-03 16:24 分类:问答Handling \r\n vs \n newlines in python on Mac vs Windows
I have a python script that gave different output when run on a Windows machine and when run on a Mac. On digging deeper, I discovered that it was because when Python read in line breaks on the Mac (f[详细]
2023-02-02 18:27 分类:问答Can I create object names from a text file in Python 2.7?
I\'m working on a game project. I\'ve created an object, Star(Object). I want to assign the name of the variables, dynamically, from a text file.[详细]
2023-02-01 20:42 分类:问答Meaning of >> in print statement
I was wondering what does print >> dbfile, key mean in python.What is the >开发者_Go百科> supposed to do?It should be noted that the >> syntax is specific to Python 2.x. In Python 3.[详细]
2023-02-01 18:44 分类:问答How to raise exception if None value encountered in dict?
I want to raise a KeyError exception if the value returned is None, but the following 开发者_运维问答throws a SyntaxError: invalid syntax exception.[详细]
2023-02-01 11:13 分类:问答Python unicode: why in one machine works but in another one it failed sometimes?
I found unicode in python really troublesome, why not Python use utf-8 for all the strings? I am in China so I have to use some Chinese string that can\'t represent by ascii, I use u\'\' to denote a s[详细]
2023-01-31 18:51 分类:问答