I have this simple python code;
import os
os.system('cmd /k "ping google.com"')
After running the code, a cmd window is displayed with the following result;
Pinging google.com [216.58.223.238] with 32 bytes of data:
Reply from 216.58.223.238: bytes=32 time=57ms TTL=120
Reply from 216.58.223.238: bytes=32 time=26ms TTL=120
Reply from 216.58.223.238: bytes=32 time=14ms TTL=120
Reply from 216.58.223.238: bytes=32 time=9ms TTL=120
Ping statistics for 216.58.223.238:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 9ms, Maximum = 57ms, Average = 26ms
How do I copy this code from the cmd window and save to a textfile using python?