lowercase

Using the lowercase function with CSV rows

夙愿已清 提交于 2019-12-05 11:53:20
I'm trying to print all data from a csv in lowercase, but I'm not having any luck. Here's what I have so far: import csv books = csv.reader(open("books.csv","rb")) for row in books: print row This prints all the content of the csv, but when I add the .lower() function, I get errors. What am I doing wrong? Try print [r.lower() for r in row] 来源: https://stackoverflow.com/questions/8265648/using-the-lowercase-function-with-csv-rows

How to set a string to all lowercase [duplicate]

折月煮酒 提交于 2019-12-05 11:19:44
This question already has an answer here: How do I lowercase a string in C? 5 answers I have a char foo[SIZE]; //(string) and have inputed it correctly using %s (as in it printfs the correct input), but now want to set it to lowercase. So I tried using if (isupper(*foo)) *foo=tolower(*foo); ie when I do: printf("%s" foo); //I get the same text with upper case The text does not seem to change. Thank you. foo isn't a pointer, so you don't want to use it as one. You also don't have to check whether a character is an upper-case letter before using tolower -- it converts upper to lower case, and

Why do upper case letters come before lower case letters in the ASCII table?

限于喜欢 提交于 2019-12-05 04:11:47
In one of my interview, the interviewer asked me why the upper case letters are before the lower case letters in ASCII table, I searched on google.com but found nothing, could anyone gave me the answer? Thx a lot! I'm only guessing, but I imagine it's because the earliest character sets had no lowercase at all. The Baudot telegraph code was only 5 bits, and CDC mainframes natively used a 6-bit code; there was no room for lowercase. When ASCII was developed as a 7-bit code which finally had enough room for lowercase letters, they were considered something of a luxury add-on, so it made sense to

Case insensitive search in Rails [duplicate]

霸气de小男生 提交于 2019-12-05 03:56:23
问题 This question already has answers here : Case-insensitive search in Rails model (19 answers) Closed 5 years ago . The best way I've found to search for things where I specifically don't want character-case to matter is: @tag = Rails.env.development? ? Category.where("LOWER(name) LIKE ?", "%#{params[:find]}%")[0] : Category.where("LOWER(name) ILIKE ?", "%#{params[:find]}%")[0] I have to have the .env finder because I use Heroku, and I haven't cared to get PostgreSQL setup on my dev machines.

How does s[i]^=32 convert upper to lower case?

孤者浪人 提交于 2019-12-05 03:42:26
int main() { string s; cout << "enter the string :" << endl; cin >> s; for (int i = 0; i < s.length(); i++) s[i] ^= 32; cout << "modified string is : " << s << endl; return 0; } I saw this code which converts uppercase to lowercase on stackoverflow. But I don't understand the line s[i] = s[i]^32 . How does it work? ^= is the exclusive-or assignment operator. 32 is 100000 in binary, so ^= 32 switches the fifth bit in the destination. In ASCII, lower and upper case letters are 32 positions apart, so this converts lower to upper case, and also the other way. But it only works for ASCII, not for

Why people don't use uppercase in the name of header files in C++?

我是研究僧i 提交于 2019-12-05 02:33:10
I was wondering why people don't use uppercase in name of header files. I see many header files with name only in lowercase. But I thought it would be more easy to read if they write them with uppercase, say "BaseClass.h", "SubClass.h", instead of "baseclass.h", "subclass.h". Why is that? Or it's just that the header files I've seen are named only in lowercase? There are systems out there which are case-sensitive (*nix), and there are systems which are traditionally case-insensitive (Windows). As a result, if you develop on *nix and create two files: baseclass.h and BaseClass.h - your code

Converting strings to a lower case in pandas [duplicate]

吃可爱长大的小学妹 提交于 2019-12-05 01:25:16
This question already has an answer here: How to lowercase a pandas dataframe string column if it has missing values? 8 answers I have a data that contains domain names: url var1 www.CNN.com xsd www.Nbc.com wer www.BBc.com xyz www.fOX.com zyx .... The data is of the Series type. I am using the following to convert url variable to lower case: df.apply(lambda x: x.astype(str).str.lower()) However, they remain the same. What am I doing wrong? df['url'] = df['url'].str.lower() should operate on the series and replace it with the lower case version. I think you need assign output back, better is

Why Java Character.toUpperCase/toLowerCase has no Locale parameter like String.toUpperCase/toLowerCase

社会主义新天地 提交于 2019-12-05 01:24:34
I am wondering that why Character.toUpperCase/toLowerCase has no Locale parameter like String.toUpperCase/toLowerCase . I have to first uppercase of a text that can be in Any language. I have 2 solutions: Use Character.toUpperCase String text = "stack overflow"; StringBuilder sb = new StringBuilder(text); sb.setCharAt(0, Character.toUpperCase(sb.charAt(0))); // No Locale parameter here. String out = sb.toString(); //Out: Stack overflow Use String.toUpperCase Locale myLocale = new Locale(locateId); String text = "stack overflow"; String text1 = text.substring(0,1).toUpperCase(myLocale ); String

lower_case_table_names=1 on Ubuntu 18.04 doesn't let mysql to start

≯℡__Kan透↙ 提交于 2019-12-05 01:18:06
问题 I have installed mysql community server 8.013 on ubuntu 18.04 and I have the following issue. I want to set lower_case_table_names=1 in order to have case insensitive table names in my db. I edited /etc/mysql/mysql.conf.d/mysqld.cnf and added the following line under [mysqld] lower_case_table_names=1 mysqld.cnf now is as follows [mysqld] pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql log-error = /var/log/mysql/error.log lower_case_table

Django LowerCaseCharField

▼魔方 西西 提交于 2019-12-04 18:36:08
问题 We implemented a LowerCaseCharField. We would be happy to hear better implementation suggestions. from django.db.models.fields import CharField class LowerCaseCharField(CharField): """ Defines a charfield which automatically converts all inputs to lowercase and saves. """ def pre_save(self, model_instance, add): """ Converts the string to lowercase before saving. """ current_value = getattr(model_instance, self.attname) setattr(model_instance, self.attname, current_value.lower()) return