I'm still learning python and I'm really new to it
I'd like to have a table that looks something like this using selenium. I'd like to print a list of text on the left and a class id on the right handside. Would you recommend me any changes I should do? I'm using driver.find_elements_by_xpath to get both values/classID
Size Availability
M In Stock
L In Stock
XL Out of Stock
XXL In Stock
My codes are:
for value,ii in zip(item_checker, size_availability):
print(value.text, ii.get_attribute('class'),)
Thank you so much for helping me if you do!
you can use the tabulate library to format output to look like fancy tables.
First example:
from tabulate import tabulate
table = [["Sun",696000,1989100000],["Earth",6371,5973.6],
["Moon",1737,73.5],["Mars",3390,641.85]]
print(tabulate(table))
Output:
----- ------ -------------
Sun 696000 1.9891e+09
Earth 6371 5973.6
Moon 1737 73.5
Mars 3390 641.85
----- ------ -------------
Second example:
print(tabulate(table, headers=["Planet","R (km)", "mass (x 10^29 kg)"]))
Output:
Planet R (km) mass (x 10^29 kg)
-------- -------- -------------------
Sun 696000 1.9891e+09
Earth 6371 5973.6
Moon 1737 73.5
Mars 3390 641.85
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.