encoding

How can I generate a unique, small, random, and user-friendly key?

醉酒当歌 提交于 2020-08-21 03:37:08
问题 A few months back I was tasked with implementing a unique and random code for our web application. The code would have to be user friendly and as small as possible, but still be essentially random (so users couldn't easily predict the next code in the sequence). It ended up generating values that looked something like this: Af3nT5Xf2 Unfortunately, I was never satisfied with the implementation. Guid's were out of the question, they were simply too big and difficult for users to type in. I was

How can I generate a unique, small, random, and user-friendly key?

怎甘沉沦 提交于 2020-08-21 03:36:35
问题 A few months back I was tasked with implementing a unique and random code for our web application. The code would have to be user friendly and as small as possible, but still be essentially random (so users couldn't easily predict the next code in the sequence). It ended up generating values that looked something like this: Af3nT5Xf2 Unfortunately, I was never satisfied with the implementation. Guid's were out of the question, they were simply too big and difficult for users to type in. I was

csv read raises “UnicodeDecodeError: 'charmap' codec can't decode…”

旧街凉风 提交于 2020-08-20 04:07:36
问题 I've read every post I can find, but my situation seems unique. I'm totally new to Python so this could be basic. I'm getting the following error: UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 70: character maps to undefined When I run the code: import csv input_file = 'input.csv' output_file = 'output.csv' cols_to_remove = [4, 6, 8, 9, 10, 11,13, 14, 19, 20, 21, 22, 23, 24] cols_to_remove = sorted(cols_to_remove, reverse=True) row_count = 0 # Current amount of rows

csv read raises “UnicodeDecodeError: 'charmap' codec can't decode…”

落爺英雄遲暮 提交于 2020-08-20 04:07:12
问题 I've read every post I can find, but my situation seems unique. I'm totally new to Python so this could be basic. I'm getting the following error: UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 70: character maps to undefined When I run the code: import csv input_file = 'input.csv' output_file = 'output.csv' cols_to_remove = [4, 6, 8, 9, 10, 11,13, 14, 19, 20, 21, 22, 23, 24] cols_to_remove = sorted(cols_to_remove, reverse=True) row_count = 0 # Current amount of rows

How to encode the ampersand if it is not already encoded?

狂风中的少年 提交于 2020-08-19 06:21:11
问题 I need a c# method to encode ampersands if they are not already encoded or part of another encoded epxression eg "tom & jill" should become "tom & jill" "tom & jill" should remain "tom & jill" "tom € jill" should remain "tom € jill" "tom <&> jill" should become "tom <&> jill" "tom "&" jill" should become "tom "&" jill" 回答1: This should do a pretty good job: text = Regex.Replace(text, @" # Match & that is not part of an HTML entity. & # Match literal &. (?! # But only if it is NOT... \w+; # an

How to encode the ampersand if it is not already encoded?

妖精的绣舞 提交于 2020-08-19 06:20:10
问题 I need a c# method to encode ampersands if they are not already encoded or part of another encoded epxression eg "tom & jill" should become "tom & jill" "tom & jill" should remain "tom & jill" "tom € jill" should remain "tom € jill" "tom <&> jill" should become "tom <&> jill" "tom "&" jill" should become "tom "&" jill" 回答1: This should do a pretty good job: text = Regex.Replace(text, @" # Match & that is not part of an HTML entity. & # Match literal &. (?! # But only if it is NOT... \w+; # an

How to check if a string contain only UTF-8 characters

喜夏-厌秋 提交于 2020-08-07 08:15:08
问题 So far I am doing something like this: def is_utf8(s): try: x=bytes(s,'utf-8').decode('utf-8', 'strict') print(x) return 1 except: return 0 the only problem is that I don't want it to print anything, I want to delete the print(x) and when I do that, the function stops functioning correctly. For example if I do : print(is_utf8("H�tst")) while the print is in the function it returns 0 otherwise it prints 1. Am i approaching the problem in a wrong way 回答1: You could use the chardet module to

Using unicode character u201c

不想你离开。 提交于 2020-08-07 04:45:07
问题 I'm a new to python and am having problems understand unicode. I'm using Python 3.4. I've spent an entire day trying to figure this out by reading about unicode including http://www.fileformat.info/info/unicode/char/201C/index.htm and http://python-notes.curiousefficiency.org/en/latest/python3/text_file_processing.html I need to refer to special quotes because they are used in the text I'm analyzing. I did test that the W7 command window can read and write the 2 special quote characters. To

Why does this Python program send empty emails when I encode it with utf-8? [duplicate]

北慕城南 提交于 2020-08-06 07:22:14
问题 This question already has answers here : smtplib sends blank message if the message contain certain characters (3 answers) Closed 15 days ago . Before encoding the msg variable, I was getting this error: UnicodeEncodeError: 'ascii' codec can't encode character '\xfc' in position 4: ordinal not in range(128) So I did some research, and finally encoded the variable: msg = (os.path.splitext(base)[0] + ': ' + text).encode('utf-8') server.sendmail('...@gmail.com', '...@gmail.com', msg) Here's the

Why does this Python program send empty emails when I encode it with utf-8? [duplicate]

↘锁芯ラ 提交于 2020-08-06 07:21:11
问题 This question already has answers here : smtplib sends blank message if the message contain certain characters (3 answers) Closed 15 days ago . Before encoding the msg variable, I was getting this error: UnicodeEncodeError: 'ascii' codec can't encode character '\xfc' in position 4: ordinal not in range(128) So I did some research, and finally encoded the variable: msg = (os.path.splitext(base)[0] + ': ' + text).encode('utf-8') server.sendmail('...@gmail.com', '...@gmail.com', msg) Here's the