• Register
0 votes
22 views

I am new to python programming I was trying to create bot service of twitch but I am totally confused about how to search for ports and hosts. The code I wrote is:

 

import socket
 def opensocket(socket):
      

      s = openscoket("irc.twitch.tv", port)

but it gives me error:

  File "main.py", line 2
    def opensocket(socket):
    ^
IndentationError: unexpected indent

I used port because I don’t know how to search for serial ports. I also have an error in my code how can I solve this? 

10 7 2
6,060 points

Please log in or register to answer this question.

1 Answer

0 votes

You can search in the link for your query:

https://pyserial.readthedocs.io/en/latest/tools.html

To get help for your ports use the command line:

python -m serial.tools.list_ports:

And also can use:

import serial.tools.list_ports
COMPORT = serial.tools.list_ports.comports()
connected = []
for things in COMPORT:
    connected.append(things.device)
print("Your port is: " + str(connected))

Happy coding

11 6 4
34,950 points

Related questions

0 votes
1 answer 92 views
92 views
Problem : I am new to MySql. The problem started when I was unable to login to Mysql using my Mysql console. It is repeatedly asking me the password and now I am unable to remember my password. Can I change my password ? And now when I am trying to open my PhpMyAdmin ... WAMP and after that deleted all my related files and then reinstalled it .But it did not fix my issue. How can I fix the issue ?
asked Feb 26, 2020 mphil 2.3k points
0 votes
1 answer 7 views
7 views
Problem : Port 80 in use by unable to open process with pid 4
asked Feb 15 Shovo210 2.9k points
0 votes
1 answer 4 views
4 views
Problem: I have python 2 and python 3 on my system. But it always select python 2 but I want to switch it according to my needs. How can i switch in between them?
asked 4 days ago jyoti goyal 2.1k points
0 votes
1 answer 80 views
80 views
I am new in Python and i am finding an answers at kodlogs where i have to read a line of space separated integers. I am using Python-2.
asked Sep 25, 2020 Daniel Anderson 4k points
0 votes
1 answer 96 views
96 views
I have a script named requests.py that imports the requests package. The script either can't access attributes from the package, or can't import them. Why isn't this working and how do I fix it? The following code raises an AttributeError. import requests res = ... ", line 1, in <module> from requests.auth import AuthBase ImportError: No module named 'requests.auth'; 'requests' is not a package
asked Oct 25, 2020 psandprop 2.4k points
0 votes
1 answer 24 views
24 views
Problem: I am creating a program that reads a file and if the first line of the file is not blank, it reads the next four lines. Calculations are performed on those lines and then the next line is read. If that line is not empty it continues. However, I am getting this error: ... with base 10: ''. It is reading the first line but can't convert it to an integer. What can I do to fix this problem?
asked Jan 9 Mashhoodch 9.3k points
0 votes
1 answer 136 views
136 views
I am trying to pip install the MySQL-python package, but I get an ImportError. Jans-MacBook-Pro:~ jan$ /Library/Frameworks/Python.framework/Versions/3.3/bin/pip-3.3 install MySQL-python Downloading/unpacking MySQL-python Running setup.py egg_info for package ... /T/pip-build/MySQL-python Storing complete log in /Users/jan/.pip/pip.log Jans-MacBook-Pro:~ jan$ Any ideas?
asked Oct 24, 2020 psandprop 2.4k points
0 votes
2 answers 66 views
66 views
1 I am unable to install Python 3.6 on Windows 7 Professional Edition 32 bits the install dialog points me to the log file whose content is as follows: [1398:1318][2018-05-30T01:15:25]i001: Burn v3.10.3.3007, Windows v6.1 (Build 7600: Service Pack 0), ... 1 is required to continue installation How can I solve this error ? Should I install a different version of Windows in order to make this work ?
asked Oct 24, 2020 psandprop 2.4k points
0 votes
2 answers 144 views
144 views
I want to run a Django application in PyCharm which works on MySQL DB. I am unable to connect my program to the database. When I am trying to install MySQLclient or MySQL-python I am getting the error: Failed building wheel for MySQLclient Please help me out in connecting my Django program with MySQL database.
asked Oct 24, 2020 psandprop 2.4k points
0 votes
1 answer 37 views
37 views
Explain with an example?
asked Oct 8, 2020 jagruthi 680 points