Author Topic: Python  (Read 5061 times)

0 Members and 1 Guest are viewing this topic.

mr.niki

  • Contributor
  • ***
  • Posts: 84
  • Karma: 1
    • View Profile
Python
« on: March 01, 2016, 01:56:46 AM »
Для примеров команд на Python
Если есть кто использует коды Python в VC
Размешайте примеры
« Last Edit: March 01, 2016, 04:25:19 AM by mr.niki »

mr.niki

  • Contributor
  • ***
  • Posts: 84
  • Karma: 1
    • View Profile
Re: Python
« Reply #1 on: March 02, 2016, 04:00:31 AM »
Есть вопрос как добавить понимание Русского языка в код Python
что бы не получать в логе такие сообщения
à¥¢ë襭 ¨­â¥à¢ « ®¦¨¤ ­¨ï ¤«ï § ¯à®á .
à¥¢ë襭 ¨­â¥à¢ « ®¦¨¤ ­¨ï ¤«ï § ¯à®á .


сам нашел ответ в начале кода добавьте
import sys

sys.setdefaultencoding('cp866')

« Last Edit: March 02, 2016, 07:57:05 AM by mr.niki »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Python
« Reply #2 on: March 02, 2016, 08:23:53 AM »
Nice. +1

 :)

mr.niki

  • Contributor
  • ***
  • Posts: 84
  • Karma: 1
    • View Profile
Re: Python
« Reply #3 on: March 03, 2016, 02:07:31 AM »
подскажите как вывести в текстовом поле: не слово а значение переменной.

tmp = 7
vc.callAction("OSD.ShowText","tmp", None)


tell me how to get into the text field : not a word and the value of the variable .

tmp = 7
vc.callAction("OSD.ShowText","tmp", None)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Python
« Reply #4 on: March 03, 2016, 08:01:49 AM »
Here is the error message that your code would have received.
Code: [Select]
TypeError: expected str, got int
The parameter must be a string, not an integer.

So it must be:
Code: [Select]
tmp = 7
vc.callAction("OSD.ShowText",str(tmp), None)

or,

Code: [Select]
tmp = '7'
vc.callAction("OSD.ShowText",tmp, None)
« Last Edit: March 03, 2016, 08:04:10 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

mr.niki

  • Contributor
  • ***
  • Posts: 84
  • Karma: 1
    • View Profile
Re: Python
« Reply #5 on: March 03, 2016, 08:47:11 AM »
thanks It works
I did so
List[str]

mr.niki

  • Contributor
  • ***
  • Posts: 84
  • Karma: 1
    • View Profile
Re: Python
« Reply #6 on: March 03, 2016, 10:43:12 AM »
well as the output variable in the form :


from System.Collections.Generic import *
tmp = 'exempl'
vc.callAction("OSD.ShowText", List[str]"[tmp]&&5000&&-10", None)

or


from System.Collections.Generic import *
maptabel = "map1"
key = "key1"
value= 1982
vc.callAction("Map.Set",list[str]("[maptabel&&key&&value]"))

SystemError: MakeGenericType on non-generic type


Line: 5 >> vc.callAction("Map.Set",List[str]("[maptabel]&&[key]&&[value]"),None)
TypeError: Не удалось привести тип объекта "System.Char" к типу "System.String".


from System.Collections.Generic import *
maptabel = "map1"
key = "key1"
value= 1982
vc.callAction("Map.Set",str("maptabel&&key&&value"),None)
but it is wrong
« Last Edit: March 03, 2016, 12:16:00 PM by mr.niki »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Python
« Reply #7 on: March 03, 2016, 01:27:52 PM »
Mr Niki.

You need to learn the basics of programming and using Python first.  We cannot teach you this because:

a) We are not in the business of teaching basic computer programming for free.
b) We do not speak the same language as you.

You must first learn the basic things about programming like "what is a variable?" and "what is a string?".  You should find another place where you can learn these things in your own language.

mr.niki

  • Contributor
  • ***
  • Posts: 84
  • Karma: 1
    • View Profile
Re: Python
« Reply #8 on: September 23, 2016, 01:27:07 PM »
Добрый день есть вопрос.  Я помню что вы говорили что не учите pyton  но прошу  подсказать хотя бы  в каком направлении искать.
И так сам вопрос :
y = "Ответ от 8.8.8.8: число байт=32 время=6мс TTL=53"
x = "Ответ от : число байт= время= TTL="
if X in Y :
я не понимаю как сравнить эти 2 строки если данные в строке Y разные но есть база которая представлена в строке X ?
   



jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Python
« Reply #9 on: September 23, 2016, 03:17:50 PM »

Tarassk

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
Re: Python
« Reply #10 on: April 05, 2017, 03:51:13 PM »
Доброго всем дня. Уважаемые администраторы помогите пожалуйста разобраться с плагином Python. Я начал осваивать вашу замечательную программу VoxCommando совсем не давно, в программировании я пока профан, поэтому прошу у вас помощи. Какие команды вписать нужно чтобы VoxCommando смог считать, вычитать, умножать и делить. И нужно ли прописывать еще какой-то код для этой функции в самом плагине. Спасибо!

Kind all day. Dear administrators, please help me understand the Python plugin. I started to master your wonderful VoxCommando program not long ago, I'm still proficient in programming, so I ask for your help. What commands should be entered so that VoxCommando can count, subtract, multiply and divide. And whether it is necessary to prescribe some more code for this function in the plug-in itself. Thank you!
« Last Edit: April 05, 2017, 04:04:41 PM by jitterjames »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Python
« Reply #11 on: April 05, 2017, 05:51:40 PM »
General info about python in VoxCommando:  http://voxcommando.com/mediawiki/index.php?title=Python

Here is a forum post where I talk about doing basic math with python:
http://voxcommando.com/forum/index.php?topic=1005.0

A more complex example that uses math:
http://voxcommando.com/forum/index.php?topic=2165.0

Maybe this helps since some of it is in Russian, and maybe you can ask Mr. Niki for help in Russian.
http://voxcommando.com/forum/index.php?topic=2459.0

mr.niki

  • Contributor
  • ***
  • Posts: 84
  • Karma: 1
    • View Profile
Re: Python
« Reply #12 on: April 24, 2017, 03:14:14 AM »
простая команда на сложение будет выглядеть так
в дереве выбора команд выберете  действие плагина питон следующие :
PY.ExecString
эта команда выполняет 1 действие плагина питон
дальше  вписываем  что нам надо выполнить
у нас  будет сложение
пример команды такой :result = {1}+{2}
в этой команде {1} и {2}  это числа из пэйлауда которые вы должны прикрепить к команде
ну  и далее если вам надо обработать результат  вокс его будет видеть как {LastResult}
к примеру
TTS.Speak   {LastResult}
вокс озвучит получившийся результат в вашем примере

более сложный пример  result = {1}{2}{3}
эта команда простой калькулятор на питоне 
если что то непонятно  то можете спрашивать тут https://vk.com/ognechannel
я там чаше бываю