escaping

How to ignore the escaping \ python list?

人走茶凉 提交于 2019-12-10 19:56:54
问题 I want to ignore the escape character in the following code. >>> a=['\%'] >>> print a ['\\%'] I want to output like ['\%'] . Is there any way to do that? 回答1: Using string_escape , unicode_escape encoding (See Python Specific Encodings): >>> a = ['\%'] >>> print str(a).decode('string_escape') ['\%'] >>> print str(a).decode('unicode_escape') ['\%'] 回答2: Couple of manual ways: >>> a=['\%'] >>> print "['{}']".format(a[0]) ['\%'] >>> print "['%s']" % a[0] ['\%'] Or more generally: >>> a=['\%', '\

Escaping in wget bash command

孤者浪人 提交于 2019-12-10 19:43:02
问题 wget -q -T 60 --retry-connrefused -t 5 --waitretry=60 --user=ftp2.company.com|company2013 --password=!company2013 -N -P data/parser/company/ ftp://ftp2.company.com/Production/somedata.zip I'm having trouble with this command, because the password contains an exclamation mark. I tried escaping with \, tried single quotes, and it either gives the output: wget: missing URL or bash: !company2013: event not found This is really demotivating... 回答1: Perhaps this part needs to be quoted to prevent

How do I send an arrow key in Perl using the Net::Telnet module?

醉酒当歌 提交于 2019-12-10 19:34:55
问题 Using the Perl module Net::Telnet, how do you send an arrow key to a telnet session so that it would be the same thing as a user pressing the down key on the keyboard? use Net::Telnet; my $t = new Net::Telnet(); my $down_key=?; #How do you send a down key in a telnet session? t->print($down_key); This list of VT102 codes says that cursor keycodes are the following: Up: Esc [ A 033 133 101 Down: Esc [ B 033 133 102 Right: Esc [ C 033 133 103 Left: Esc [ D 033 133 104 How would I send these in

Add apostrophe to last name search

你。 提交于 2019-12-10 19:13:50
问题 I created a proc that will return a list of applicants by lastname. I have a problem searching Applicants with last name that has apostrophe (Example O'Connor). Could you please help finding those applicants: Below is my Search Code: if Rtrim(@FirstName) <> '' begin If(Len(@FirstName) < 30) and (CharIndex('%', @FirstName) = 0) and @FirstName != '' Set @FirstName = char(39) + @FirstName + '%' + char(39) end if Rtrim(@LastName) <> '' begin If(Len(@LastName) < 60) and (CharIndex('%', @LastName)

Unescape _xHHHH_ XML escape sequences using Python

冷暖自知 提交于 2019-12-10 18:57:29
问题 I'm using Python 2.x [not negotiable] to read XML documents [created by others] that allow the content of many elements to contain characters that are not valid XML characters by escaping them using the _xHHHH_ convention e.g. ASCII BEL aka U+0007 is represented by the 7-character sequence u"_x0007_" . Neither the functionality that allows representation of any old character in the document nor the manner of escaping is negotiable. I'm parsing the documents using cElementTree or lxml [semi

Handling node containing inner escaped XML

随声附和 提交于 2019-12-10 18:44:48
问题 I have an XML document with a node containing the escaped XML serialization of another object, as in this example: <attribute> <value> <map> <item> <src>something</src> <dest>something else</dest> </item> </map> </value> </attribute> How can I apply an xslt template to the inner xml? In particolar, I would like to get an html table with the couples src/dest: | src | dest | | something | something else | 回答1: I would do this as a two-step operation. Step1.xsl: <xsl:stylesheet version="1.0"

Including decimal equivalent of a char in a character array

大憨熊 提交于 2019-12-10 17:57:26
问题 How do I create a character array using decimal/hexadecimal representation of characters instead of actual characters. Reason I ask is because I am writing C code and I need to create a string that includes characters that are not used in English language. That string would then be parsed and displayed to an LCD Screen. For example '\0' decodes to 0, and '\n' to 10. Are there any more of these special characters that i can sacrifice to display custom characters. I could send "Temperature is

Sitecore Fast Query - How to search for text containing special characters (such as an apostrophe)?

╄→尐↘猪︶ㄣ 提交于 2019-12-10 17:30:06
问题 Perhaps I'm blind but I can't find any documentation on escaping special characters for Sitecore's fast query. For example, I want to search content items that contain the following text in their description: "hot n' tasty" Note: I've tried the following escaping: var searchTerm = "hot n'' tasty"; // thought it might need to be escaped for sql var searchTerm = "#hot n' tasty#"; // this is how you do some other sitecore escaping var searchTerm = "hot n\' tasty"; Sample application code: var

I can't add a new line to c++ string

隐身守侯 提交于 2019-12-10 17:22:35
问题 How do you add a new line to a c++ string? I'm trying to read a file but when I try to append '\n' it doesn't work. std::string m_strFileData; while( DataBegin != DataEnd ) { m_strFileData += *DataBegin; m_strFileData += '\n'; DataBegin++; } 回答1: If you have a lot of lines to process, using stringstream could be more efficient. ostringstream lines; lines << "Line 1" << endl; lines << "Line 2" << endl; cout << lines.str(); // .str() is a string Output: Line 1 Line 2 回答2: Sorry about the late

How to separate paragraphs in a string

时光总嘲笑我的痴心妄想 提交于 2019-12-10 16:45:37
问题 Hi guys I really need your help. I was trying to take a multi-line string which was concluded of a few paragraphs and split it into a few individual texts. I realized that whenever I skip a line there is a sequence of \n\r in there. Afterwards I thought that each new line starts with a \n and end with a \r. Therefor, I wrote the following code. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; namespace