try:
....
except ConnectionError:
print('Ошибка, надо загружать файл по новой')
{
"path": """c:\Program Files\Notepad++\notepad++.exe"""
}
import pywinauto
import json
f = open("test.txt",'r',encoding = 'utf-8')
config= f.read()
catalog = json.loads(config)['path']
app=pywinauto.Application().connect(catalog)
app.kill()
class DontNeedToDo(Exception):
pass
@bot.message_handler(func=lambda message: message.chat.id not in users)
def CheckUser(message):
bot.send_message(message.chat.id, "Извини, но ты не можешь работать с ботом")
raise DontNeedToDo()
>>> units = {"k":1000,"m":1000000}
>>> num=["11.4k" , "550" , "1.23m" , "30"]
>>> result=[]
>>> for n in num:
... try:
... result.append( float(n) ) #try to comber it to a number
... except ValueError:
... unit=n[-1] #get the letter
... n = float( n[:-1] ) #convert all but the letter
... result.append( n * units[unit] )
>>> result
[11400.0, 550.0, 1230000.0, 30.0]