I tried to input and output Russian language in my file but failed it keeps displaying something like \xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82' when I run it in Terminal inside of python with print \xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82'
print "Привет!"
a = raw_input()
print "Как у тебя дела сегодня?"
a_1 = raw_input()
print "Понятно.Тогда у тебя есть планы вечром?"
a_2 = raw_input()
print "Пока."
a_3 = raw_input()
print "Давой завтра!"
print "Бывают люди бледные бывают тусклые бывают блестящие...Она только сказала \"%r\" \"%r\" \"%r\" \"%r\"... " %(
a,a_1,a_2,a_3)
In Terminal:
MacBook-Pro:mystuff admin$ python ex11.py
Привет!
Привет
Как у тебя дела сегодня?
Нормально
Понятно Тогда у тебя есть планы вечром?
Да Я буду позвонить с другой
Пока
Пока
Давой завтра
Бывают люди бледные бывают тусклые бывают блестящие...Она только сказала "'\xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82'" "'\xd0\x9d\xd0\xbe\xd1\x80\xd0\xbc\xd0\xb0\xd0\xbb\xd1\x8c\xd0\xbd\xd0\xbe'" "'\xd0\x94\xd0\xb0 \xd0\xaf \xd0\xb1\xd1\x83\xd0\xb4\xd1\x83 \xd0\xbf\xd0\xbe\xd0\xb7\xd0\xb2\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x82\xd1\x8c \xd1\x81 \xd0\x98\xd0\xbb\xd1\x8c\xd0\xbe\xd0\xb9'" "'\xd0\x9f\xd0\xbe\xd0\xba\xd0\xb0'"...
You should use%s instead of
%r.
What %r does is that it looks for a class function called __repr__ of the object and returns __repr__(). You input a string Привет, and its __repr__() returns those hex numbers, which is the internal representation of the string.
If you use %s, it then looks for another function called __str__, and it will returns the string in the correct way.
Or you could use
print "Бывают люди бледные бывают тусклые бывают блестящие...Она только сказала \"{}\" \"{}\" \"{}\" \"{}\"... ".format(a,a_1,a_2,a_3)
try %s instead of %r:
\"%s\" \"%s\" \"%s\" \"%s\"... " %(a,a_1,a_2,a_3)
Related
I have the following list of strings:
list_of_str = ['Notification message', 'Warning message', 'This is the |xxx - show| message.', 'Notification message is defined by |xxx - show|', 'Notification message']
How can I get the string that is closest to the tail and contains show|, and substitute show| by Placeholder|?
The expected result:
list_of_str = ['Notification message', 'Warning message', 'This is the |xxx - show| message.', 'Notification message is defined by |xxx - Placeholder|', 'Notification message']
Reverse iteration, find and replace:
for i, s in enumerate(reversed(list_of_str), 1):
if 'show|' in s:
list_of_str[-i] = s.replace('show|', 'Placeholder|')
break
This should work
# reverse the list
for i, x in enumerate(list_of_str[::-1]):
# replace the first instance and break loop
if 'show|' in x:
list_of_str[len(list_of_str)-i-1] = x.replace('show|', 'Placeholder|')
break
list_of_str
['Notification message',
'Warning message',
'This is the |xxx - show| message.',
'Notification message is defined by |xxx - Placeholder|',
'Notification message']
Try this:
idx = next((idx for idx in reversed(range(len(list_of_str)))
if 'show|' in list_of_str[idx]), 0)
list_of_str[idx] = list_of_str[idx].replace('show|', 'Placeholder|')
You first find the last index containing "show|" and then you do the replacement.
Another option:
for idx in reversed(range(len(list_of_str))):
if 'show|' in list_of_str[idx]:
list_of_str[idx] = list_of_str[idx].replace('show|', 'Placeholder|')
break
I need to get pieplot with labels in Cyrillic symbols, that is in df.index
plt.pie(df['reg_created'], labels = df.index)
So, it's return error:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)
df.index:
Index([u'Бизнес', u'Вечеринки', u'Выставки', u'Гражданские проекты',
u'Для детей', u'Другие развлечения', u'Другие события', u'Еда',
u'ИТ и интернет', u'Иностранные языки', u'Интеллектуальные игры',
u'Искусство и культура', u'Кино', u'Концерты', u'Красота и здоровье',
u'Наука', u'Образование за рубежом', u'Психология и самопознание',
u'Спорт', u'Театры', u'Хобби и творчество', u'Экскурсии и путешествия'],
dtype='object', name=u'name')
matplotlib.pyplot.pie label parameter shoud be a list, so if I try:
df.index.tolist()
returns:
['\xd0\x91\xd0\xb8\xd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\xd1\x82\xd0\xb5\xd1\x88\xd0\xb5\xd1\x81\xd1\x82\xd0\xb2\xd0\xb8\xd1\x8f']
if I print list by element:
for i in df.index.tolist():
print i
returns Cyrillic text
Бизнес
Вечеринки
Выставки
Гражданские проекты
...
Why I have difference in print list of Cyrillic text and print that list by element?
And what I shoud get to pyplot.pie label param for Cyrillic labels?
You got your answer in the error message, the charters are decoded as ASCII and not as UTF-8
https://stackoverflow.com/a/10406161
https://stackoverflow.com/a/36454865
I need to grab info about software version and build data (maybe loading file name too) from page download GIS "Panorama"
I am using python and grab. Now i have sctript like this:
from grab import Grab
g = Grab(log_file='out.html')
g.go('http://www.gisinfo.ru/download/download.htm')
for table in g.doc.select('//div[#id="article_header_rubric"]/following-sibling::table[2]'):
#if test.text().startswith('Профессиона'):
for tr in table.select('tr'):
type(tr.select('td'))
for td in tr.select('td'):
#if td.text().startswith('Профессиональная ГИС'):
print (td.text())
And result is like this:
Драйвер электронного ключа x86 (версия 6.20, 32-разрядные операционные системы,
для Панорама 10 и выше)
15.08.2013
9,6 Mb
drivers.zip
Сервер Guardant Net (версия 5.5.0.10, для Панорама 10 и 11)
25.07.2013
4.1 Mb
gnserver.zip
Сервер Guardant Net (версия 6.3.1.713, для Панорама 12)
11.10.2016
4 Mb
netkey6.zip
Программа для диагностики ключей
13.07.2016
2,6 Mb
diagnostics.zip
Than i filtering what i want:
from grab import Grab
g = Grab(log_file='out.html')
g.go('http://www.gisinfo.ru/download/download.htm')
for table in g.doc.select('//div[#id="article_header_rubric"]/following-sibling::table[2]'):
#if test.text().startswith('Профессиона'):
for tr in table.select('tr'):
type(tr.select('td'))
for td in tr.select('td'):
if td.text().startswith('Профессиональная ГИС'):
print (td.text())
And result now:
Профессиональная ГИС
Профессиональная ГИС "Панорама" (версия 12.4.0, для платформы "x64")
Профессиональная ГИС "Панорама" (версия 12.3.2, для платформы "x64", на английском языке)
Профессиональная ГИС "Карта 2011" (версия 11.13.5.7)
But i want result like this:
Профессиональная ГИС "Панорама" (версия 12.4.0, для платформы "x64")
29.12.2016
347 Mb
panorama12x64.zip
Профессиональная ГИС "Панорама" (версия 12.3.2, для платформы "x64", на английском языке)
24.11.2016
376 Mb
panorama12x64en.zip
Профессиональная ГИС "Карта 2011" (версия 11.13.5.7)
11.01.2017
263 Mb
panorama11.zip
And ideas?
tr.select('td') returns an iterable. In you current code, you test the string on each iteration, so you only print the first one.
You should store an iterator, take its first value and test it, and if it matches print all values from the iterable:
for tr in table.select('tr'):
type(tr.select('td'))
it = iter(tr.select('td'))
td = next(it) # process first field in row
if td.text().startswith('Профессиональная ГИС'):
print (td.text())
for td in it: # print remaining fields
print(td.text())
is ok for me like this:
from grab import Grab
g = Grab(log_file='out.html')
g.go('http://www.gisinfo.ru/download/download.htm')
list = []
for table in g.doc.select('//div[#id="article_header_rubric"]/following-sibling::table[2]'):
for tr in table.select('tr'):
type(tr.select('td'))
for td in tr.select('td'):
list.append(td.text())
for i in list:
indexi=list.index(i)
if (i.startswith('Профессиональная ГИС "Панорама" (версия 12') and i.endswith('x64")')):
panorama12onsite = list[indexi]
panorama12onsitedata = list[indexi+1]
elif i.startswith('Профессиональная ГИС "Карта 2011"'):
panorama11onsite = list[indexi]
panorama11onsitedata = list[indexi+1]
elif (i.startswith('Профессиональный векторизатор "Панорама-редактор" (версия 12') and i.endswith('x64")')):
panedit12onsite = list[indexi]
panedit12onsitedata = list[indexi+1]
elif i.startswith('Профессиональный векторизатор "Панорама-редактор" (версия 11'):
panedit11onsite = list[indexi]
panedit11onsitedata = list[indexi+1]
print (panorama12onsite)
print (panorama12onsitedata)
print (panorama11onsite)
print (panorama11onsitedata)
print (panedit12onsite)
print (panedit12onsitedata)
print (panedit11onsite)
print (panedit11onsitedata)
Now i can use this variables in other part of script (merge vs downloaded version and download new if exists). Thanks all for help
I have written a wlst script to create multiple connection factories. Code is as below :
def createJMSConnFac(systemModuleName,ConnectionFactoryJNDIName,connectionFactoryName):
cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName)
cmo.createConnectionFactory(connectionFactoryName)
cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName)
cmo.setJNDIName(ConnectionFactoryJNDIName)
print "Created a ConnectionFactory !!"
cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName+'/SecurityParams/'+connectionFactoryName)
cmo.setAttachJMSXUserId(false)
cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName)
cmo.setDefaultTargetingEnabled(true)
print "Targeted the ConnectionFactory !!"
And the loop from which this method gets called is :
y=1
while(y <= int(total_conf)):
print '----------- Connection Factory Creation ---------'
print 'Total Conf :' +total_conf
conf_name=configProps.get("conf_name"+ str(a) + "." +str(y))
conf_jndi=configProps.get("conf_jndi"+ str(a) + "." +str(y))
print 'Conf Name :' +conf_name
print 'Conf JNDI :' +conf_jndi
print 'Conf JMS Mod Name :'+jms_mod_name
print a
print y
createJMSConnFac(jms_mod_name,conf_jndi,conf_name)
y = y + 1
Interesting thing to note here is that : It creates connfac1 properly however as soon as it iterates for second time , it throws me an error saying :
WLSTException: Error cding to the MBean on line 4
The values of jms_mod_name , conf_jndi and conf_name are being printed properly in both the iterations.
Is there anything else that I may be missing here ? Request your help
Thanks ,
Bhavin
I was able to create 3(or more) CFs with this code :
def createJMSConnFac(systemModuleName,ConnectionFactoryJNDIName,connectionFactoryName):
cmo=cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName)
cmo.createConnectionFactory(connectionFactoryName)
cmo=cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName)
cmo.setJNDIName(ConnectionFactoryJNDIName)
print "Created a ConnectionFactory !!"
cmo=cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName+'/SecurityParams/'+connectionFactoryName)
cmo.setAttachJMSXUserId(false)
cmo=cd('/JMSSystemResources/'+systemModuleName+'/JMSResource/'+systemModuleName+'/ConnectionFactories/'+connectionFactoryName)
cmo.setDefaultTargetingEnabled(true)
print "Targeted the ConnectionFactory !!"
connect("weblogic","password","t3://host:port")
edit()
startEdit()
y=1
while(y <= 3):
print '----------- Connection Factory Creation ---------'
conf_name="conf_name." +str(y)
conf_jndi="conf_jndi." +str(y)
print 'Conf Name :' +conf_name
print 'Conf JNDI :' +conf_jndi
#print a
print y
createJMSConnFac('testModule',conf_jndi,conf_name)
y = y + 1
save()
activate(block="true")
disconnect()
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
So I have a function called LoopingSpace. It takes no parameter
def loopingSpace():
for i in range (3):
print ""
i +=1
Whenever, it's called. It will print three blank lines.
For example; if I type
def loopingSpace():
for i in range (3):
print ""
i +=1
print"Hi"
loopingSpace()
print"Hi"
It will nicely output
Hi
Hi # As you can see three blanks.
However, when you put this function in a huge syntax like.
from random import randint
#Variabel
#--------------------------------------------------------------------
playername=[]
#Player disini mencatat skor. Jumlah Uang/Nilai Saham/Total harta/Health
playerOne=[0,0,0,0]
playerTwo=[0,0,0,0]
playerThree=[0,0,0,0]
#Stok disini mencatat banyak saham yang dimiliki peserta. A/B/C/D/E/F/G/H
stockOne=[0,0,0,0,0,0,0,0]
stockTwo=[0,0,0,0,0,0,0,0]
stockThree=[0,0,0,0,0,0,0,0]
#Tool disini mencatat apabila peserta memiliki barang. Diamond/Buy/Sell/Diamond/Poison
toolOne=[0,0,0,0,0]
toolTwo=[0,0,0,0,0]
toolThree=[0,0,0,0,0]
#Price disini mencatat harga saham. A/B/C/D/E/F/G/H
price=[0,0,0,0,0,0,0,0]
#clockTracker. Day dan turn counter
clockTracker=[0,0]
hari=["Senin","Selasa","Rabu","Kamis","Jumat","Sabtu","Minggu"]
listing=[playerOne,playerTwo,playerThree]
toolListing=[toolOne,toolTwo,toolThree]
#Nama saham
stockName=["Alama Inc.","Bwah! Bwah! Bwah! LCD","CUIT! CUIT CV","Dong Inc.","Eeeeeeeeeeeeah!","Foo il company.","Gogogogo Ind.","Halllo."
#--------------------------------------------------------------------
# THIS IS THE CODE. THIS IS THE CODE. THIS IS THE CODE
def loopingSpace():
for i in range (3):
print ""
i +=1
#
def startingTheGame():
loopingSpace()
print "Selamat datang di Stock Game."
print "Anda mau [M]ain atau Baca [A]turan?"
answer= raw_input(">")
answerRecognizerOne(answer)
#
def answerRecognizerOne(inbox):
inbox.lower()
if inbox=="a":
ruleExplainer()
elif inbox=="m":
gameStarter()
else:
loopingSpace()
print "Syntax tidak dimengerti. Mohon ulangi."
loopingSpace()
startingTheGame()
#
def answerRecognizerTwo(inbox):
inbox.lower()
if inbox=="y":
print "Kita akan mengambil kartu kesempatan lagi"
cekKartuKesempatan()
elif inbox=="n":
print "Game akan dilanjutkan"
#
def ruleExplainer():
loopingSpace()
print "Aturan:"
print "Dalam awal giliran kamu, kamu akan mengambil kartu kesempatan."
print "Kartu kesempatan kamu akan memberikan kamu hak untuk mengubah harga saham."
print "Lalu kamu bisa jual atau beli saham."
print "Kamu juga dapat bekerja pada Weekend, sehingga kamu dapat uang tambahan."
print "Setelah 33 hari. Peserta dengan uang tertinggi akan menang."
loopingSpace()
startingTheGame()
#
def gameSetUp():
playerOne=[250,0,0]
playerOne[2]=playerOne[0]+playerOne[1]
playerTwo=[250,0,0]
playerTwo[2]=playerTwo[0]+playerTwo[1]
playerThree=[250,0,0]
playerThree[2]=playerThree[0]+playerThree[1]
price=[30,30,30,30,30,30,30,30]
print playerOne
print playerTwo
print playerThree
print price
loopingSpace()
print "Saya akan memberi kamu semua $250 untuk berinvestasi."
print "Kamu juga akan memasuki dunia Wallsheet."
print "Sebuah bursa saham di dunia Kryxban."
print "Semoga beruntung."
loopingSpace()
answer= raw_input ("Tekan enter untuk melanjutkan")
clockTracker=[1,0]
print "Good Luck"
loopingSpace()
kartuKesempatan()
#
def refreshScore():
playerOne[1]=0
for i in range(8):
playerOne[1]+=(stockOne[i]*price[i])
playerTwo [1]=0
for i in range(8):
playerTwo[1]+=(stockTwo[i]*price[i])
playerThree [1]=0
for i in range(8):
playerThree[1]+=(stockThree[i]*price[i])
playerOne[2] = playerOne[0] + playerOne[1]
playerTwo[2] = playerTwo[0] + playerTwo[1]
playerThree[2] = playerThree[0] + playerThree[1]
# Fungsi printScore -> Mengprint skor
def printScore():
print playername[0]+": Uang: $"+str(playerOne[0])+" Saham: $"+str(playerOne[1])+" Total: $"+str(playerOne[2])
print playername[1]+": Uang: $"+str(playerTwo[0])+" Saham: $"+str(playerTwo[1])+" Total: $"+str(playerTwo[2])
print playername[2]+": Uang: $"+str(playerThree[0])+" Saham: $"+str(playerThree[1])+" Total: $"+str(playerThree[2])
# Fungsi kartuKesempatan -> Menjalankan fase Kartu Kesempatan
def kartuKesempatan ():
refreshScore()
print "Sekarang adalah giliran " + playername[clockTracker[1]]
print ""
printScore()
loopingSpace()
print "Kamu mengambil kartu kesempatan"
answer = raw_input ("Kamu siap? Tekan enter jika kamu siap?")
cekKartuKesempatan()
#
def gameStarter():
print loopingSpace()
for i in range(3):
answer= raw_input("Masukan nama pemain ke " + str(i+1)+ ">")
playername.append(answer)
gameSetUp()
#
def cekKartuKesempatan():
foo = randint(1,2)
if foo==1:
print "**KAMU MENDAPAT $25**"
print "Dompet kamu tiba-tiba memberat."
print "Kamu mengecek dompetmu."
print "Ada $25 muncul!"
(listing[clockTracker[1]][0])+=25
updateScore()
checkForToool()
elif foo==2:
print "**SAHAM NAIK 10%**"
woo=0
for i in range(8):
woo= floor.(price[i]/10)
if woo != 0:
price[i] += woo
print "Saham "+stockName[i]+" naik $"+woo
checkForTool()
def checkForTool()
if (toolListing[clockTracker[1]][0])!=0:
print "Anda mempunyai 'Kesempatan Extra'. Mau dipakai? ( Anda punya "+str.(toolListing[clockTracker[1]][0])+" ) [y]es /[n]o"
answer= raw_input(">")
answerRecognizerTwo(answer)
It threw this error.
File "main.py", line 31
def loopingSpace():
^
SyntaxError: invalid syntax
Note: I use online executor
Note: The online executor respectively use 2.7.4 and 2.7.5
Where do I do wrong?
NOTE: When I delete the loopingSpace(): function from the code completely, it will then complain about the next function in line which in this case startingTheGame(), and so on
PS: This pyt is formed as a game. I will call one function (startingTheGame()) and this function will call other function and so on. I pretty sure you get the point.
Sincerely,
DEO
The syntax error is actually on the line before it:
stockName=["Alama Inc.","Bwah! Bwah! Bwah! LCD","CUIT! CUIT CV",
"Dong Inc.","Eeeeeeeeeeeeah!","Foo il company.",
"Gogogogo Ind.","Halllo."
You have to add a closing bracket ]:
stockName=["Alama Inc.","Bwah! Bwah! Bwah! LCD","CUIT! CUIT CV",
"Dong Inc.","Eeeeeeeeeeeeah!","Foo il company.",
"Gogogogo Ind.","Halllo."]
Currently, your list is defined as:
stockName=["Alama Inc.","Bwah! Bwah! Bwah! LCD","CUIT! CUIT CV","Dong Inc.","Eeeeeeeeeeeeah!","Foo il company.","Gogogogo Ind.","Halllo."
Notice how there is no ] at the end of the list. Thus, you have technically not defined the list yet, and so python tries to continue making the list. It then reads the next line with text, which is def loopingSpace():. As the syntax [..., "Halllo." def loopingSpace() isn't proper syntax, a SyntaxError is raised at the line of definition.